﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Data;

namespace Client
{
    public partial class LoginForm : Form
    {
        private MainForm parent;

        public LoginForm(MainForm parent)
        {
            InitializeComponent();
            this.SetParent(parent);
        }

        private void cancelBtn_Click(object sender, EventArgs e)
        {
            this.CloseForm();
        }

        public void CloseForm()
        {
            this.Close();
        }

        private void loginBtn_Click(object sender, EventArgs e)
        {
           Tractor.Name = AgentTxt.Text;
            try {
                Tractor.NewGame();
                this.CloseForm();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message, "Błąd", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }

        public void SetParent(MainForm parent)
        {
            this.parent = parent;
        }

        public MainForm GetParent()
        {
            return this.parent;
        }

        private void AddressTxt_TextChanged(object sender, EventArgs e)
        {

        }

        private void label7_Click(object sender, EventArgs e)
        {

        }

        private void LoginForm_Load(object sender, EventArgs e)
        {

        }
    }
}
